473,426 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Clearing a DropDownList

Vi
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.
Nov 18 '05 #1
4 19154
Hi,

This should work:

document.getElementById('dropdownlistname').option s.length = 0;

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.

Nov 18 '05 #2
In the code-behind, how about myList.items.clear?

"Vi" wrote:
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.

Nov 18 '05 #3
Vi
From the Code Behid, please...

Thanks,

"Ken Dopierala Jr." wrote:
Hi,

This should work:

document.getElementById('dropdownlistname').option s.length = 0;

Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?

Thanks.


Nov 18 '05 #4
Vi wrote:
Hi,
Is there a way to clear a DropDownList from code behind, something similar
to myDropDownList.length=0 on the client?


The DropDownList has an Items property with methods for adding and
removing ListItems. There's Clear(), which will remove *all* items
(DDLID.Items.Clear()), and there's also methods like Add(), Insert(),
Remove(), and RemoveAt().

hth

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Smith | last post by:
Hi folks, I have a form with ASP.NET web controls. At the end of the form there's the "Clear" button to clear the available values and start over. How do I do that? The following did not work...
4
by: VB Programmer | last post by:
I have a dropdownlist which I populated on page_load. This works fine. I simply do a ddlMyDdl.Items.Add(xxx) I also have a button which references the CURRENTLY selected item in the ddl like...
2
by: PK9 | last post by:
Can someone help me with the syntax for clearing (removing) all items out of an asp:dropdownlist from the code behind? Is there a clear method? -- PK9
8
by: gv | last post by:
Ok, Hi all, new to asp.net. Simple question with web forms I have a Dropdownlist and a listbox, I want to click on and item in the dropdownlist and show items in listbox. that simple I...
4
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing...
1
by: renor321 | last post by:
Hello, I've searched the groups unsuccessfully to the solution to this problem. I've seen a few others making note of it, but it didn't seem like there were any solutions. I have a drop down...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
4
by: gobblegob | last post by:
I am trying to clear the array STR but it does not clear it. This sub is in a module. Dim STR As Array 'Dim str(6) As String STR =...
0
by: RajenderG | last post by:
in a page dropdownlist binding dynamically and assigned font color for few list items... and page having buttons .. when i click on button -- page post back happening and dropdown list items text...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.